import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class test0 {
    public static void main(String[] args) throws IOException {
        System.out.println(count("C:\\Users\\陈宇森\\Desktop\\新建文本文档.txt","中"));
    }
    static int count (String url,String s) throws IOException {
        int count=0;
        File file = new File(url);
        InputStreamReader input = new InputStreamReader(new FileInputStream(file));
        BufferedReader reader = new BufferedReader(input);
        List<String> list = new ArrayList();
        while (true){
            String str = reader.readLine();
            if (str==null){
                break;
            }
            else {
                list.add(str);
            }
        }
        String str="";
        for (String st : list){
            str+=st;
        }
        for(int i=0;i<=str.length()-s.length();i++){
            if (str.startsWith(s, i)){
                count++;
            }
        }
        reader.close();
        input.close();
        return count;
    }
}
